package com.sjz.han.industry.adapters;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sjz.han.industry.R;
import com.sjz.han.industry.activites.WaitJhMemberDetailActivity;
import com.sjz.han.industry.entities.JFRecordEntity;

import java.util.ArrayList;
import java.util.List;


/**
 *我的积分适配器
 */
public class MyIntegralAdapter extends RecyclerView.Adapter<MyIntegralAdapter.ViewHolder> {
    private Context context;
    private List<JFRecordEntity.JFRecordData.JFRecord> datas=new ArrayList<>();
    public MyIntegralAdapter(Context context) {
        this.context=context;
    }

    @Override
    public int getItemCount() {
        return datas == null ? 0 : datas.size();
//        return 5;
    }
    public void setAdapterDatas(List<JFRecordEntity.JFRecordData.JFRecord> datas){
        this.datas=datas;
        notifyDataSetChanged();
    }
    @Override
    public MyIntegralAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyIntegralAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_myintegral_item, parent, false));
    }

    @Override
    public void onBindViewHolder(MyIntegralAdapter.ViewHolder holder, final int position) {
        if(!TextUtils.isEmpty(datas.get(position).createTime)){
            holder.wdjf_time_tv.setText(datas.get(position).createTime.substring(0,10).replace("-","."));
        }else{
            holder.wdjf_time_tv.setText("---");
        }
//        是status   0  未结账 1  已结账
        if("1".equals(datas.get(position).status)){
            holder.wdjf_buser_tv.setText("（已结算）");
        }else{
            holder.wdjf_buser_tv.setText("（未结算）");
        }

      holder.wdjf_jfvaluer_tv.setText(datas.get(position).money+"积分");
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        public TextView wdjf_time_tv,wdjf_buser_tv,wdjf_jfvaluer_tv;
        public ViewHolder(View itemView) {
            super(itemView);
            wdjf_time_tv=(TextView)itemView.findViewById(R.id.wdjf_time_tv);
            wdjf_buser_tv=(TextView)itemView.findViewById(R.id.wdjf_buser_tv);
            wdjf_jfvaluer_tv=(TextView)itemView.findViewById(R.id.wdjf_jfvaluer_tv);
        }

    }
}